package com.optionexplorer.data;

import java.util.Date;

import com.optionexplorer.util.DateUtils;
import com.optionexplorer.util.NumberUtils;

public class PutOption extends StockOption {

	
	public PutOption( float stockPr,
					   String symb, 
					   Date expDate, 
					   float strikePrice, 
					   float premium, 
					   long volume, 
					   long openInt) {
		super(stockPr,symb,expDate,strikePrice,premium,volume,openInt);
		computeMetrics();
	}
	
	public String getType() {
		return StockOption.PUT_OPTION;
	}
	
	/**
	 * Compute the additional metrics for puts
	 */
	private void computeMetrics() {
		
		this.discount = this.premium;
		this.percentDiscount = NumberUtils.roundTwoDecimals(this.premium / this.stockPrice * 100);
		this.downBuf = NumberUtils.roundTwoDecimals(this.stockPrice - this.strikePrice + this.premium);
		this.percentDownBuf = NumberUtils.roundTwoDecimals(((this.downBuf / this.stockPrice)*100));
		this.roe = this.premium;
		this.percentRoe = NumberUtils.roundTwoDecimals(this.premium / this.strikePrice * 100);
		
		
		this.remDays = DateUtils.getDaysRemaining(this.getExpirationDate());
		this.annualYield = NumberUtils.roundTwoDecimals(this.percentDiscount * 365/remDays);
		this.annualDownBuf = NumberUtils.roundTwoDecimals(this.percentDownBuf * 365/remDays);		
		
		return;
	}
	
	public String printAdditionalMetrics() {
		
		StringBuilder sb = new StringBuilder();
		sb.append(this.roe + "\t");
		sb.append(this.percentRoe + "%\t");
		sb.append(this.downBuf + "\t");
		sb.append(this.percentDownBuf + "%\t");
		sb.append(this.remDays + "\t");
		sb.append(this.annualYield + "%\t");
		
		return sb.toString();
	}
	
	
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
